package com.example.demo.permission.menu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.demo.common.UserUtil;
import com.example.demo.permission.menu.dao.MenuMapper;
import com.example.demo.permission.menu.pojo.Menu;

/**
 * 
 * <p>
 * 功能描述： 菜单service
 * </p>
 * 
 * @author lixh
 * @date 2019年3月6日 上午10:22:29
 * @company chinobot
 * @version 1.0
 */
@Service
@Transactional
@CacheConfig(cacheNames = "menus_cache")
public class MenuService {
	@Autowired
	MenuMapper menuMapper;

	/**
	 * 
	 * 方法描述: 获取全部菜单
	 * 
	 * @return
	 * @author lixh
	 */
	public List<Menu> getAllMenu() {
		return menuMapper.getAllMenu();
	}

	public List<Menu> getMenuByUserId() {
		Long long1 = UserUtil.getCurrentUser().getId().longValue();
		return menuMapper.getMenusByUserId(long1);
	}

	public List<Menu> menuTree() {
		return menuMapper.menuTree();
	}

	public List<Long> getMenuByRid(Long rid) {
		return menuMapper.getMenuByRid(rid);
	}

}
